//
//  LYContactModel.swift
//  WeChat
//
//  Created by mac on 2018/8/3.
//  Copyright © 2018年 RRC. All rights reserved.
//

import Foundation
import SwiftyJSON

@objc class ContactModel: NSObject {
    ///头像小图
    var avatarSmallURL:String?
    ///中文名称
    var chinseName:String?
    ///中文名称拼音
    var nameSpell:String?
    var phone:String?
    var userId:String?
    
    override init() {
        super.init()
    }
    
    func mapping(map:JSON) {
        avatarSmallURL = map["avatar_url"].stringValue
        chinseName = map["name"].stringValue
        nameSpell = map["name_spell"].stringValue
        phone = map["phone"].stringValue
        userId = map["userid"].stringValue
        
    }
    
    @objc func compareContact(_ contactModel:ContactModel) -> ComparisonResult {
        let result = nameSpell?.compare(contactModel.nameSpell!)
        return result!
    }
    
}

enum ContactModelEnum:Int{
    case newFriends = 0
    case publicAccout
    case groupChat
    case tags
    
    var model:ContactModel {
        let model = ContactModel()
        switch self {
        case .groupChat:
            model.chinseName = "群聊"
            model.avatarSmallURL = "http://ww1.sinaimg.cn/large/6a011e49jw1f18hercci7j2030030glf.jpg"
            return model
            
        case .publicAccout:
            model.chinseName = "公众号"
            model.avatarSmallURL = "http://ww2.sinaimg.cn/large/6a011e49jw1f18hkv6i5kj20300303yb.jpg"
            return model
            
        case .newFriends:
            model.chinseName = "新的朋友"
            model.avatarSmallURL = "http://ww4.sinaimg.cn/large/6a011e49jw1f18hftp0foj2030030dfn.jpg"
            return model
            
        case .tags:
            model.chinseName = "标签"
            model.avatarSmallURL = "http://ww2.sinaimg.cn/large/6a011e49jw1f18hh48jr3j2030030743.jpg"
            return model
            
        }
    }
    
}
